<!--
 * @Description: 系统设置
 * @Author: HuiSir<273250950@qq.com>
 * @Date: 2025-06-22 19:25:26
 * @LastEditTime: 2025-09-15 18:10:24
-->
<template>
  <fy-form-page
    v-model="formData"
    v-model:options="formOptions"
    title="系统设置"
    labelWidth="160px"
    inputWidth="600px"
    :loading="loading"
    @submit="handleSubmit"
  />
</template>

<script lang="ts" setup>
import { ref } from "vue";
import { ElMessage } from "element-plus";
import useFormOptions from "./useFormOptions";
import { SubmitCallbacks } from "@/ui";

// 配置项
defineOptions({ name: "Settings", isFull: true });

// 表格配置
const formOptions = useFormOptions();
const loading = ref(false);
const formData = ref({
  name: null,
  up1: null,
  up2: null,
  up3: null,
  fileUploadPath: null,
  picUploadPath: null,
  language: null,
  defaultPassword: null,
  canResetPassword: null,
  sidebar: null,
  about: null,
});

const handleSubmit = async (callbacks: SubmitCallbacks) => {
  await callbacks.uploadSubmit();
  console.log(formData.value);
  const valid = await callbacks.validate();
  if (valid) {
    setTimeout(() => {
      callbacks.closeLoading();
      ElMessage.success("保存成功");
    }, 1000);
  }
};
</script>
